<?php
/*
 * Created on 14.10.2007
 * filename: startup.php5
 * 
 * this class - autoloader - loads requested classes
 */

 if(version_compare(phpversion(),'5.1.0','<')) {
	die('require PHP5.1');
 }

 include('config.php5'); 
 include(COREPATH.'libs/sanitize_vars.php');
 include(COREPATH.'libs/Utf8Win.php');

 function __autoload($class_name) {

 	//loading Smarty
 	if($class_name == 'Smarty') {
 		$file = COREPATH."libs/Smarty/libs/" . $class_name . '.class.php';
	// loading models
 	} else if(preg_match("/Model_([^_]*)(?:_([^_]*))?/", $class_name, $matches) ) {
		array_shift($matches);
		$file = COREPATH . 'models' . DIRSEP . strtolower(join('/',$matches)).ext;
 	// loading exceptions
 	} else if(ereg("Exception", $class_name) ) {
 		$filename = strtolower(preg_replace("/(.*)Exception$/", "$1", $class_name )).ext;
 		$file = COREPATH . 'classes/exceptions' . DIRSEP . $filename;
    // loading classes
    } else {
	 	$filename = strtolower($class_name).ext;
 		$file = COREPATH . 'classes' . DIRSEP . $filename;
 	}

 	if(!file_exists($file)) {
 		return false;
 	}
	 	
 	include ($file);
 }

 $registry = new Registry;

?>
